var info = [];
var oN = [];
var Email = [];
for(i=0; i < document.getElementsByTagName("td").length; i++){
tsting = document.getElementsByTagName("td")[i].innerHTML;
info.push(tsting);
}

var stopper = parseInt(prompt('How many transactions to pull details from? (Must be under 1,100)', 'Most recent = 1 anything before will be 2,3,4 etc.'), 10);


var getOrder = stopper * 12;
getOrder = getOrder + 58;
var getMail = stopper * 12;
getMail = getMail + 67;
if(getMail - 10 > document.getElementsByTagName("td").length){
alert('Too many orders!');
}
else{}

var failNum = 0;
failNum = parseInt(failNum, 1);

var getOn = function(){
  for(x=58; x < getOrder; x = x + 12){
    var url = document.getElementsByTagName("td")[x].innerHTML;
 var y = x + 1;
 var failD = document.getElementsByTagName("td")[y].innerHTML;
var failNote = '';
 if(failD.search("Failed") > -1){
 failNote = '  (FAILED)';
 failNum = failNum++;
 }
 else{
 failNote = '';
 }
    var a = url.indexOf("tid=");
    var b = url.indexOf('&amp');
    var c = url.substring(a + 4, b);
    var d = c + failNote;
    oN.push(d);
  }
};
var getEmail = function(){
  for(y=67; y < getMail; y = y + 12){
    var eMail = document.getElementsByTagName("td")[y].innerHTML;
    eMail = eMail.toLowerCase();
    Email.push(eMail);
  }
};
var failNotes = '';
if(failNum > 0){
failNotes = '(' + failNum + ' of ' + stopper + ' failed)';
}
else{
failNotes = '';
}

getEmail(getMail);
getOn(getOrder);
//Remove Dupes---!
var newArray=new Array();
label:for(var i=0; i<Email.length;i++ )
{  
for(var j=0; j<newArray.length;j++ )
{
if(newArray[j]==Email[i]) 
continue label;
}
newArray[newArray.length] = Email[i];
}
Email = newArray;
//Remove Dupes---!
Email = Email.toString();
Email = Email.replace(/,/g, '\n');
oN = oN.toString();
oN = oN.replace(/,/g, '\n');
window.prompt ("Copy to clipboard: Ctrl+C, Enter", 'Order Numbers: \n' + failNotes + '\n'+ oN + '\n \nEmail Addresses: \n \n' + Email);